package com.market.cash.ui.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.market.cash.R
import com.market.cash.utils.adapter.CashRootRecyclerViewAdapter
import com.market.cash.utils.adapter.CashRootViewHolderHelper
import org.json.JSONObject

/**
 * CashRoot
 * @Author wwdeng
 * @CreateTime: 2024/10/18 10:55
 * @Annotation：主页Tab
 */
class CashRootMainTabAdapter(recyclerView: RecyclerView?) : CashRootRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.cash_main_tab_item) {

    override fun setItemChildListener(helper: CashRootViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout)
    }

    override fun fillData(helper: CashRootViewHolderHelper, position: Int, model: JSONObject) {
        val imgIcon = helper.getImageView(R.id.imgIcon)
        when(model.optBoolean("isSelect", false)){
            true -> {
                imgIcon.setImageResource(model.optInt("tabImageSelected"))
                helper.setVisibility(R.id.vPoint,View.VISIBLE)
            }
            else -> {
                imgIcon.setImageResource(model.optInt("tabImageNormal"))
                helper.setVisibility(R.id.vPoint,View.INVISIBLE)
            }
        }
    }
}